// 搜索插入位置
/**
 * @param {number[]} nums
 * @param {number} target
 * @return {number}
 */
 var searchInsert = function(nums, target) {　
    /*let i=0;
    while(nums[i]<target){
        i++;
    }
    return i;*/
     const n = nums.length;
        let left = 0, right = n - 1, ans = n;
        while (left <= right) {
            let mid = ((right - left) >> 1) + left;
            if (target <= nums[mid]) {
                ans = mid;
                right = mid - 1;
            } else {
                left = mid + 1;
            }
        }
        return ans;
    };